/**
 * Created by shitao on 15/10/13.
 */
(function () {
    angular.module('my-tabs')
        .config(routesConfig);
    routesConfig.$inject = ['$stateProvider', '$urlRouterProvider'];

    function routesConfig($stateProvider, $urlRouterProvider) {

        $stateProvider
            // 抽象父状态，用来设置Tabs
            .state('main', {
                url: '/main',
                abstract: true,
                templateUrl: 'views/main.html',
                controller: 'mainCtrl as vm'
            })
            // "首页"页面
            .state('main.home', {
                url: '/home',
                views: {
                    'main-home': {
                        templateUrl: 'views/home.html',
                        controller: 'homeCtrl as vm'
                    }
                }
            })
            // "具体应用"页面
            .state('main.app', {
                url: '/apps/:appId',
                views: {
                    'main-home': {
                        templateUrl: 'views/home/app-detail.html',
                        controller: 'appDetailCtrl as vm'
                    }
                }
            })
            // "朋友"页面
            .state('main.friend', {
                url: '/friend',
                views: {
                    'main-friend': {
                        templateUrl: 'views/friend/list.html',
                        controller: 'friendCtrl as vm'
                    }
                }
            })
            // "朋友对话"页面
            .state('main.friend-dialog', {
                url: '/friend/:friendId',
                views: {
                    'main-friend': {
                        templateUrl: 'views/friend/dialog.html',
                        controller: 'friendDialogCtrl as vm'
                    }
                }
            })
            // "资讯明细"页面
            .state('main.news-detail', {
                url: '/news/:id',
                views: {
                    'main-approvals': {
                        templateUrl: 'views/news/detail.html',
                        controller: 'newsDetailCtrl as vm'
                    }
                }
            })
            // "发现"页面
            .state('main.explore', {
                url: '/explore',
                views: {
                    'main-explore': {
                        templateUrl: 'views/explore/index.html',
                        controller: 'exploreCtrl as vm'
                    }
                }
            })

            // "webview"页面
            .state('main.frame', {
                url: '/frames/:frameId',
                views: {
                    'main-explore': {
                        templateUrl: 'views/home/frame.html',
                        controller: 'frameCtrl as vm'
                    }
                }
            })
            // "商户"页面
            .state('main.store', {
                url: '/stores/:storeId',
                views: {
                    'main-explore': {
                        templateUrl: 'views/explore/store.html',
                        controller: 'storeCtrl as vm'
                    }
                }
            })
            // "我的"页面
            .state('main.me', {
                url: '/me',
                views: {
                    'main-me': {
                        templateUrl: 'views/me/index.html',
                        controller: 'meCtrl as vm'
                    }
                }
            })
            // "我的信息"页面
            .state('main.info', {
                url: '/info',
                views: {
                    'main-me': {
                        templateUrl: 'views/me/info.html',
                        controller: 'infoCtrl as vm'
                    }
                }
            })

        // 默认进入“首页”标签页面
        $urlRouterProvider.otherwise('/main/home');

    };
})();
